﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Markup;
using System.Text;

namespace SmartSpace.Silverlight
{
    public partial class SlRowNumberColumn : DataGridTemplateColumn
    {
        public SlRowNumberColumn()
        {
            StringBuilder sbIcon = new StringBuilder();
            sbIcon.Append("<DataTemplate ");
            sbIcon.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' ");
            sbIcon.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
            sbIcon.Append(">");
            sbIcon.Append("<Border BorderThickness=\"0,0,1,1\" BorderBrush=\"#FFD0D0D0\">");
            sbIcon.Append("<Border.Background>");
            sbIcon.Append("<ImageBrush ImageSource=\"/SmartSpace.Silverlight;component/Control/Images/rowheader.png\" />");
            sbIcon.Append("</Border.Background>");
            sbIcon.Append("<TextBlock VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\"/>");
            sbIcon.Append("</Border>");
            sbIcon.Append("</DataTemplate>");
            this.CellTemplate = XamlReader.Load(sbIcon.ToString()) as DataTemplate;

            this.Width = new DataGridLength(25);
            this.IsReadOnly = true;
            this.CanUserReorder = false;
            this.CanUserResize = false;
            this.CanUserSort = false;
        }

        protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
        {
            FrameworkElement element = base.GenerateElement(cell, dataItem);
            
            
            return element;
        }
    }
}
